<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui, user-scalable=no">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>登录 - {{ config('app.name')  }}</title>
    @include('backend.layouts.header')
    <style>
        .lyear-wrapper {
            position: relative;
        }

        .lyear-login {
            display: flex !important;
            min-height: 100vh;
            align-items: center !important;
            justify-content: center !important;
        }

        .lyear-login:after {
            content: '';
            min-height: inherit;
            font-size: 0;
        }

        .login-center {
            background: #fff;
            min-width: 29.25rem;
            padding: 2.14286em 3.57143em;
            border-radius: 5px;
            margin: 2.85714em;
        }

        .login-header {
            margin-bottom: 1.5rem !important;
        }

        .login-center .has-feedback.feedback-left .form-control {
            padding-left: 38px;
            padding-right: 12px;
        }

        .login-center .has-feedback.feedback-left .form-control-feedback {
            left: 0;
            right: auto;
            width: 38px;
            height: 38px;
            line-height: 38px;
            z-index: 4;
            color: #dcdcdc;
        }

        .login-center .has-feedback.feedback-left.row .form-control-feedback {
            left: 15px;
        }

        .login-header {
            font-size: 30px;
        }
    </style>
</head>

<body>
<div class="row lyear-wrapper">
    <div class="lyear-login">
        <div class="login-center">
            <div class="login-header text-center">
                {{config('app.name')}}
            </div>
            <form id="loginForm" method="post">
                <div class="form-group has-feedback feedback-left">
                    <input type="text" placeholder="请输入您的用户名" class="form-control" name="username" id="txtUsername"/>
                    <span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
                </div>
                <div class="form-group has-feedback feedback-left">
                    <input type="password" placeholder="请输入密码" class="form-control" id="txtPassword" name="password"/>
                    <span class="mdi mdi-lock form-control-feedback" aria-hidden="true"></span>
                </div>
                <div class="form-group has-feedback feedback-left row">
                    <div class="col-xs-7">
                        <input type="text" name="captcha" id="txtCaptcha" class="form-control" placeholder="验证码">
                        <span class="mdi mdi-check-all form-control-feedback" aria-hidden="true"></span>
                    </div>
                    <div class="col-xs-5">
                        <img src="{{captcha_src('math')}}" class="pull-right" id="captcha" style="cursor: pointer;"
                             onclick="this.src='{{captcha_src('math')}}&r='+Math.random();" title="点击刷新" alt="captcha"/>
                    </div>
                </div>
                <div class="form-group">
                    <button class="btn btn-block btn-primary" type="submit">登录</button>
                </div>
            </form>
            <hr>
            <footer class="col-sm-12 text-center">
                <p class="m-b-0">Copyright © {{date('Y')}} <a href="https://gitee.com/wlfs/lyearAdmin">王桥江</a>. All right reserved</p>
            </footer>
        </div>
    </div>
</div>
@include('backend.layouts.footer',['widget_params'=>['mode'=>'login']])
<script type="text/javascript">
    $('#loginForm').submit(function (e) {
        var username = $('#txtUsername').val();
        var password = $('#txtPassword').val();
        var captcha = $('#txtCaptcha').val();
        if (!/^\S{2,20}$/.test(username)) {
            layer.msg('用户名必须6到20位，且不能出现空格', {
                icon: 7,
                time: 2000
            });
            return false;
        }
        if (!/^\S{6,20}$/.test(password)) {
            layer.msg('密码必须6到20位，且不能出现空格', {
                icon: 7,
                time: 2000
            });
            return false;
        }
        if (!/^[1-9]\d*$/.test(captcha)) {
            layer.msg('验证码必须是数字', {
                icon: 7,
                time: 2000
            });
            return false;
        }

        systemUtil.ajax('{{url($baseRoute.'loging')}}').setData({
            username: username,
            password: password,
            captcha: captcha
        }).send().then(function (res) {
                if (res.url) {
                    location.href = res.url;
                } else {
                    location.href = "{{url('admin/index')}}";
                }
            }).catch(function () {
            $('#captcha').attr('src', "{{captcha_src('math')}}&r=" + Math.random());
        }).showMsg();
        return false;
    });
</script>
</body>
</html>
